﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeIT.MemCached;
using System.Configuration;

namespace mymemcached2014
{
    /// <summary>
    /// 获取172.28.1.210:11211,172.28.1.211:11211
    /// </summary>
    public class MyMemcachedTools210
    {
        static string cacheName = "gjhqmemsdBak";
        static MyMemcachedTools210()
        {
            //服务器ip及端口172.28.5.31:11211
            try
            {
                String[] serverlist = { "172.28.1.210:11211", "172.28.1.211:11211" };
                MemcachedClient.Setup(cacheName, serverlist);
                MemcachedClient cache = MemcachedClient.GetInstance(cacheName);
                cache.SendReceiveTimeout = 5000;
                cache.ConnectTimeout = 5000;
                cache.MinPoolSize = 1;
                cache.MaxPoolSize = 5;
            }
            catch (Exception e)
            { MemcachedClient cache = MemcachedClient.GetInstance(cacheName); }
        }

        public object GetClient()
        {
            return MemcachedClient.GetInstance(cacheName);
        }

        public void Add(string key, object obj, int hours, int minutes, int seconds)
        {
            throw new NotImplementedException();
        }

        public void Remove(string key)
        {
            throw new NotImplementedException();
        }

        public void FlushAll()
        {
            throw new NotImplementedException();
        }

        public byte[] Get(string key)
        {
            MemcachedClient cache = (MemcachedClient)GetClient();
            return (byte[])cache.Get(key);
        }

    }

    /// <summary>
    /// 获取172.28.5.57:11211
    /// </summary>
    public class MyMemcachedTools57
    {
        static string cacheName = "gjhqmeddmBak";
        static MyMemcachedTools57()
        {
            //服务器ip及端口172.28.5.31:11211
            try
            {
                String[] serverlist = { "172.28.5.57:11211" };
                MemcachedClient.Setup(cacheName, serverlist);
                MemcachedClient cache = MemcachedClient.GetInstance(cacheName);
                cache.SendReceiveTimeout = 5000;
                cache.ConnectTimeout = 5000;
                cache.MinPoolSize = 1;
                cache.MaxPoolSize = 5;
            }
            catch (Exception e)
            { MemcachedClient cache = MemcachedClient.GetInstance(cacheName); }
        }

        public object GetClient()
        {
            return MemcachedClient.GetInstance(cacheName);
        }

        public void Add(string key, object obj, int hours, int minutes, int seconds)
        {
            throw new NotImplementedException();
        }

        public void Remove(string key)
        {
            throw new NotImplementedException();
        }

        public void FlushAll()
        {
            throw new NotImplementedException();
        }

        public byte[] Get(string key)
        {
            MemcachedClient cache = (MemcachedClient)GetClient();
            return (byte[])cache.Get(key);
        }

    }


    /// <summary>
    /// 获取172.28.5.57:11211
    /// </summary>
    public class MyMemcachedTools12
    {
        static string cacheName = "sdfdsfsdfsdf";
        static MyMemcachedTools12()
        {
     
            try
            {
                String[] serverlist = {"172.28.20.12:11211" };
                MemcachedClient.Setup(cacheName, serverlist);
                MemcachedClient cache = MemcachedClient.GetInstance(cacheName);
                cache.SendReceiveTimeout = 5000;
                cache.ConnectTimeout = 5000;
                cache.MinPoolSize = 1;
                cache.MaxPoolSize = 5;
            }
            catch (Exception e)
            { MemcachedClient cache = MemcachedClient.GetInstance(cacheName); }
        }

        public object GetClient()
        {
            return MemcachedClient.GetInstance(cacheName);
        }

        public void Add(string key, object obj, int hours, int minutes, int seconds)
        {
            throw new NotImplementedException();
        }

        public void Remove(string key)
        {
            throw new NotImplementedException();
        }

        public void FlushAll()
        {
            throw new NotImplementedException();
        }

        public byte[] Get(string key)
        {
            MemcachedClient cache = (MemcachedClient)GetClient();
            return (byte[])cache.Get(key);
        }

    }

}
